Reference Materials > Setting Bi-directional Digital Bits

Setting the Direction of the Digital Bits

Instruments with Bi-directional Digital bits require you to set the direction prior to reading or outputting digital signals.

Setting the Direction of the Digital Bits

The directions of the Digital Bits on DI-71x Instruments MUST be set using the DATAQ Instruments Hardware Manager. View the DATAQ Instruments Hardware Manager Help file for more information.

The directions of the Digital Bits on DI-148 and DI-158 Instruments should be set using di_digout. di_digout is a 16-bit integer property.

Note: You may set the direction of the digital bits for Models DI-148 and DI-158 Instruments using the DATAQ Instruments Hardware Manager. This will write the direction directly to the instruments. However, each time the instrument is powered, the digital bits automatically reset to inputs requiring you to reset the bits each time.

Bit 15 determines whether the lower 8 bits are used for digital output or if they are used to determine the direction of the digital ports.

Bit 0 1
15 indicates the lower 8 bits are for digital output
(0 for low signal, 1 for high signal)
indicates the lower 8 bits determine direction
(1 for input, 0 for output)

Bits 8 to 14 are reserved and should be 0.

To specify digital bit directions on multiple DI-1110, DI-1120, DI-2008, DI-2108, DI-2108-P, DI-4108, DI-4208, or DI-4730 devices, to each direction configuration value add 256 times the number of connected devices with lower serial numbers or listed ahead of it in the argument to di_open.

Bits 0 to 7 correspond to the digital ports on the hardware and determine direction if Bit 15 is set to 1 or determine a high/low level signal if Bit 15 is set to 0.

  when Bit 15 = 0 when Bit 15 = 1
Port Bit 0 1 0 1
D7 7 low high output input
D6 6 low high output input
D5 5 low high output input
D4 4 low high output input
D3 3 low high output input
D2 2 low high output input
D1 1 low high output input
D0 0 low high output input

To set all Digital ports to outputs you would use the following: di_digout(&H8000)

To set all Digital ports to inputs you would use the following: di_digout(&H8000 + 255)

To set only the second digital port to an input you would use the following: di_digout(&H8000 + 2)

Note: Bits corresponding to ports that do not exist on your hardware are ignored. To read Inputs after starting and stopping a scan, use the di_digin property concentrating only on the bits designated as Inputs. To read inputs during a scan, enable a digital channel in the scan list and look at the most significant byte of the 16-bit integer data scanned for that channel.

Sending output signals

Use an 16 bit integer and di_digout to send output signals. Bits programmed as inputs will ignore the command. To select among multiple DI-1110, DI-1120, DI-2008, DI-2108, DI-2108-P, DI-4108, DI-4208, or DI-4730 devices, to each output value add 256 times the number of connected devices with lower serial numbers or listed ahead of it in the argument to di_open.

di_digout(255) will output 1 on all digital outputs - only ports programmed as outputs will see the signal.

di_digout(0) will output 0 on all digital outputs - only ports designated as outputs will see the signal.

di_digout(2) will output 1 on D1 - as long as D1 is designated as an output.

 

 

 

 

 

Copyright © DATAQ Instruments, Inc.